import Vue from 'vue/dist/vue.js'
import VueRouter from 'vue-router'// 引入路由
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import app from './src-component/fileImport'
import VueUploadComponent from 'vue-upload-component'
import config from './src-config/config'

// 使用注册使用路由
Vue.use(config)
Vue.use(VueRouter)
Vue.use(ElementUI, { size: 'small', zIndex: 3000 });
Vue.component('file-upload', VueUploadComponent);

Vue.filter('formatSize', function (size) {
    size = size || 0
    if (size > 1024 * 1024 * 1024 * 1024) {
        return (size / 1024 / 1024 / 1024 / 1024).toFixed(2) + ' TB'
    } else if (size > 1024 * 1024 * 1024) {
        return (size / 1024 / 1024 / 1024).toFixed(2) + ' GB'
    } else if (size > 1024 * 1024) {
        return (size / 1024 / 1024).toFixed(2) + ' MB'
    } else if (size > 1024) {
        return (size / 1024).toFixed(2) + ' KB'
    }
    return size.toString() + ' B'
})


// 定义该模块的路由
const router = new VueRouter({
    routes: [
        { path: '/', component: app },
    ]
})

// //引入路由,并把模块渲染到节点html节点上
new Vue({
    router: router, // 路由模块渲染,
    provide() {
        return {
            reload: this.reload
        };
    },
    data(){
      return {
          isRouterAlive: true
      }
    },
    methods:{
        reload(){
            this.isRouterAlive = false
            this.$nextTick(function () {
                this.isRouterAlive = true
            })
        }
    }
}).$mount('#app')